<!--
 * createor: zc
 * email: zc8023zs@163.com
 * create_time: 2020/3/14 13:46:24
 *-->
<template>
  <el-container>
    <el-main>
      <el-table
        :key="tableKey"
        :data="listData" :height="tableHeight"
        highlight-current-row border fit
        v-loading="tabLoading">
        <el-table-column type="index" label=" " width="50" align="center" :index="table_index"></el-table-column>
        <el-table-column prop="id" label="主键id" width="120" align="center" />
        <el-table-column prop="article_id" label="内容id" width="120" align="center" />
        <el-table-column prop="user_id" label="操作用户id" width="120" align="center" />
        <el-table-column prop="user_name" label="操作用户名" width="120" align="center" />
        <el-table-column prop="create_time" label="操作时间" width="120" align="center" :formatter="dateFormat"/>
        <el-table-column prop="note" label="备注" width="120" align="center" />
        <el-table-column
          :label="$t('table.actions')"
          align="center"
          width="230"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button type="primary" @click="onInfoPage(scope)">{{ $t('table.info') }}</el-button>
          </template>
        </el-table-column> 
      </el-table>
      <pagination
        v-show="pagecnt>1"
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.size"
        @pagination="getList"
      />
    </el-main>
  </el-container>
</template>
<style scoped>
body .app-container .el-container,
body .app-container .el-header,
body .app-container .el-main,
body .el-container,
body .el-header,
body .el-main {
  padding: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
</style>
<script>
import Pagination from "@/components/Pagination";
import { Loading } from "element-ui";
import {
  article_logSelect,article_logSelecttree,article_logSelectpage
} from '@/api/project/article/project_article_article_log'
export default {
  name: "a_articlea_article_log",
  components: { Pagination },
  filters: {},
  data() {
    return {
      tabLoading: false,
      tableKey: 'article_article_log_table',
      listData: null,
      total: 0,
      pagecnt: 0,
      tableHeight: (window.innerHeight-100),
      listQuery: {
        page: 1,
        size: 20,
      },
    };
  },
  mounted(){
    let that =this;
    window.onresize=()=>{
      this.tableHeight = (window.innerHeight-210);
    }
  },
  created() {
    this.getList();
  },
  methods: {
    onSearch(){
      if(command && command=='all'){
        this.resetQuery();
      }
      this.listQuery.page=1;
      this.getList();
    },
    onInfoPage(scope){
      var view = this.$store.state.permission.routesMap["/article/article_log_info"];
      this.$router.push({ path: view.path, query: {m_id:view.code_aes,id:scope.row.id} })
    },
    dateFormat(row, column, cellValue, index){
      return this.$moment(cellValue).format("YYYY/MM/DD");
    },
    commentFormat(row, column, cellValue, index){
      try {
        var comment = "";
        var array = comment.split(':')[1].split(' ');
        var obj = {};
        for(var i=0;i<array.length;i++){
          var split = array[i].split('=');
          obj[split[1]]=split[0];
        }
        if(obj[cellValue]) return obj[cellValue];
        return cellValue;
      } catch (error) {
        return cellValue;
      }
    },
    table_index(index) {
      return (this.listQuery.page - 1) * this.listQuery.size + index + 1;
    },
    getList() {
      this.tabLoading=true;
      article_logSelectpage(this.$qs.stringify(this.listQuery,{ indices: false })).then(r=>{
        this.listData = r.dataArray.dataList;
        this.total = r.dataArray.dataCount;
        this.pagecnt = r.dataArray.pageCount;
        this.tabLoading=false;
      }).catch(()=>{
        this.tabLoading=false;
      });
    }
  }
};
</script>